<<xAct`xTensor`

DefConstantSymbol[dim, PrintAs->"d"]

DefManifold[M, dim, IndexRange[a,h]]

Let’s define the metric

DefMetric[-1, metric[-a,-b],CD,{";","∇"},PrintAs->"g"]

metric[-a,-b]

%//InputForm

contraction with inverse metric gives identity

metric[-a,-b]metric[b,c]

covariant derivative compatible with the metric

CD[-a][metric[-b,-c]]

curvature tensors

{RiemannCD[-a,-b,-c,-d], RicciCD[-a,-b], RicciScalarCD[]}

automatic contractions of the Riemann and Ricci tensors

RiemannCD[-a,-c,-b,c]

RicciCD[-a,a]

definition of tensors

DefTensor[v[a],M]
DefTensor[F[-a,-b],M,Antisymmetric[{-a,-b}]]

there is no automatic checking of expressions

F[-a,-b] v[b] +v[a]

%//Validate

F[-a,-b]F[-c,-b]

%//Validate

covariant derivative of a vector

CD[-a][v[b]]

%//ChangeCovD//ScreenDollarIndices

ChangeCovD[%%,CD,PD]//ScreenDollarIndices

%//ChristoffelToGradMetric//ScreenDollarIndices

metric is not contracted automatically

RiemannCD[-a,-b,-c,-d]metric[b,d]

%//ContractMetric

ToCanonical:

reorders indices to the canonical form

RiemannCD[-a,-b,-c,-d]+RiemannCD[-b,-a,-c,-d]

%//ToCanonical

vanishing contractions due to the symmetries

F[-a,-b]v[a]v[b]

%//ToCanonical

Substitutions

this is wrong:

DefTensor[w[a],M]
rule = w[a_]->F[a,b]v[-b]

w[b]/.rule

MakeRule solves the problem with dummy indices

rule=MakeRule[{w[a], F[a,b]v[-b]}]

w[b]/.rule

%//ScreenDollarIndices

ScreenDollarIndices can be called automatically:

$PrePrint=ScreenDollarIndices;

w[a]w[b]w[c]/.rule

substitution does not work for w[-b]

w[-b]/.rule

additional options to MakeRule

rule=MakeRule[{w[a], F[a,b]v[-b]},MetricOn->All, ContractMetrics->True]

w[-b]/.rule

MakeRule also takes care about symmetries

rule=MakeRule[{F[-a,-b]v[b],w[-a]}]

{F[-a,-b]v[b],F[-a,-b]v[a]}
%/.rule

Example - check of the Riemann tensor symmetry

RiemannCD[-a,-b,-c,d]+RiemannCD[-b,-c,-a,d]+RiemannCD[-c,-a,-b,d]

%//ChangeCurvature

ChangeCurvature[%%,CD,PD]

%//ToCanonical

Example - check of the Bianchi identity

3Antisymmetrize[CD[-e][RiemannCD[-a,-b,-c,d]], {-e,-a,-b}]//ToCanonical

%//ChangeCovD

ChangeCovD[%%,CD,PD]

%//ChangeCurvature

%//ToCanonical